package com.szty.libarytest.other

import android.content.Intent
import android.os.Bundle
import android.os.CountDownTimer
import androidx.appcompat.app.AppCompatActivity
import com.szty.libarytest.R
import com.szty.libarytest.dialog.DialogActivity
import kotlinx.android.synthetic.main.activity_timer.*

class TimerActivity : AppCompatActivity() {
    val timer = object : CountDownTimer(1000 * 10, 100) {
        override fun onFinish() {
            //时辰已到
            "时间到".loge()
        }

        override fun onTick(millisUntilFinished: Long) {
            //每一秒任务
            "时间:${millisUntilFinished / 1000}".loge()
        }

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_timer)
        btn_start_timer.setOnClickListener {
            val intent = Intent(this, DialogActivity::class.java)
            intent.putExtra("info", "开始")
            startActivity(intent)
        }
        btn_stop_timer.setOnClickListener {
            val intent = Intent(this, DialogActivity::class.java)
            intent.putExtra("info", "停止")
            startActivity(intent)
//            timer.cancel()
        }
    }
}